/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Responsive container - iframe vs full screen */
#gameContainer {
    width: 100%;
    height: 450px; /* Default iframe height */
    position: relative;
    background: linear-gradient(180deg, #87CEEB 0%, #98FB98 100%);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Full screen mode detection */
@media (min-height: 500px) {
    #gameContainer {
        height: 90vh;
    }
}

/* Game header with controls and info */
#gameHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(5px);
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
    height: 50px;
    flex-shrink: 0;
}

#gameInfo {
    display: flex;
    gap: 15px;
    font-size: 14px;
    font-weight: bold;
    color: #2c3e50;
}

#gameControls {
    display: flex;
    gap: 8px;
}

#gameControls button, #vocabBtn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-width: 40px;
    min-height: 40px;
}

#gameControls button:hover, #vocabBtn:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Progress bar */
#progressContainer {
    height: 8px;
    background: rgba(0, 0, 0, 0.2);
    margin: 0 12px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}

#progressBar {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 4px;
}

/* Prompt display */
#promptDisplay {
    text-align: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.95);
    margin: 8px 12px;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

#modeIndicator {
    font-size: 12px;
    color: #7f8c8d;
    margin-bottom: 4px;
    font-weight: bold;
}

#currentPrompt {
    font-size: 18px;
    font-weight: bold;
    color: #2c3e50;
    min-height: 24px;
    word-wrap: break-word;
}

/* Main game area */
#gameArea {
    flex: 1;
    position: relative;
    overflow: hidden;
    margin: 0 12px 8px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

/* Detective character */
#detective {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 40px;
    z-index: 10;
    transition: left 0.2s ease;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.3));
}

/* Falling cards */
.falling-card {
    position: absolute;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #bdc3c7;
    border-radius: 12px;
    padding: 12px;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    color: #2c3e50;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    min-width: 80px;
    max-width: 120px;
    word-wrap: break-word;
    transition: all 0.3s ease;
    cursor: pointer;
}

.falling-card.correct {
    border-color: #27ae60;
    background: rgba(46, 204, 113, 0.9);
    color: white;
    animation: correctPulse 0.5s ease;
}

.falling-card.incorrect {
    border-color: #e74c3c;
    background: rgba(231, 76, 60, 0.9);
    color: white;
    animation: incorrectShake 0.5s ease;
}

@keyframes correctPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes incorrectShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Touch controls */
#touchControls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    height: 60px;
}

.touch-btn, .start-btn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 12px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    min-width: 60px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.start-btn {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    font-size: 16px;
    padding: 0 20px;
    flex: 1;
    margin: 0 12px;
    max-width: 200px;
}

.touch-btn:active, .start-btn:active {
    transform: scale(0.95);
}

.touch-btn:hover, .start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 24px;
    max-width: 90%;
    max-height: 80%;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal h2 {
    color: #2c3e50;
    margin-bottom: 16px;
    text-align: center;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

.modal-buttons button, #closeHelpBtn, #closeLeaderboardBtn, #closeVocabBtn {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
    min-height: 44px;
}

.modal-buttons button:hover, #closeHelpBtn:hover, #closeLeaderboardBtn:hover, #closeVocabBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

/* Help content */
.help-content {
    text-align: left;
    line-height: 1.6;
}

.help-content ul {
    margin: 8px 0 8px 20px;
}

.help-content li {
    margin: 4px 0;
}

/* Leaderboard */
#leaderboardList {
    min-height: 200px;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    margin: 4px 0;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #3498db;
}

.leaderboard-entry.top-score {
    background: linear-gradient(135deg, #f1c40f, #f39c12);
    color: white;
    border-left-color: #e67e22;
}

/* Vocabulary management */
#vocabManagement {
    position: absolute;
    top: 60px;
    right: 12px;
    z-index: 100;
}

.vocab-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    justify-content: center;
}

.vocab-controls button {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    min-height: 36px;
}

#vocabList {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 16px;
}

.vocab-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    margin: 4px 0;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 12px;
}

.vocab-item button {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 10px;
    min-height: 24px;
}

.add-vocab {
    display: flex;
    gap: 8px;
    align-items: center;
}

.add-vocab input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    min-height: 36px;
}

.add-vocab button {
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 12px;
    min-height: 36px;
}

/* Feedback display */
#feedbackDisplay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    z-index: 500;
    animation: feedbackPop 1s ease;
}

#feedbackDisplay.hidden {
    display: none;
}

@keyframes feedbackPop {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* Power-up display */
#powerUpDisplay {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(155, 89, 182, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    display: none;
    z-index: 100;
    animation: powerUpGlow 2s infinite;
}

@keyframes powerUpGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(155, 89, 182, 0.5); }
    50% { box-shadow: 0 0 20px rgba(155, 89, 182, 0.8); }
}

/* Input styling */
input[type="text"] {
    padding: 12px;
    border: 2px solid #bdc3c7;
    border-radius: 8px;
    font-size: 16px;
    margin: 8px 0;
    width: 100%;
    max-width: 200px;
    text-align: center;
    min-height: 44px;
}

input[type="text"]:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 8px rgba(52, 152, 219, 0.3);
}

/* Responsive adjustments */
@media (max-width: 480px) {
    #gameInfo {
        font-size: 12px;
        gap: 8px;
    }
    
    #currentPrompt {
        font-size: 16px;
    }
    
    .falling-card {
        font-size: 12px;
        padding: 8px;
        min-width: 70px;
        max-width: 100px;
    }
    
    #detective {
        font-size: 32px;
    }
    
    .modal-content {
        padding: 16px;
        margin: 20px;
    }
}

/* Animation classes */
.level-up {
    animation: levelUpBounce 1s ease;
}

@keyframes levelUpBounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

.score-pop {
    animation: scorePop 0.5s ease;
}

@keyframes scorePop {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}